package com.sky.myshop.services.impl;

import com.sky.myshop.services.ShapeEnum;
import com.sky.myshop.services.ShapeSeries;
import org.springframework.data.redis.core.index.PathBasedRedisIndexDefinition;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
public class PieShapeSeries implements ShapeSeries {
    @Override
    public ShapeEnum getShape() {
        return ShapeEnum.PIE;
    }

    @Override
    public List getShapeData(List<Map> sdata) {
        List<Entry> ents = new ArrayList<>();
        for (Map mp:sdata){
            ents.add(new Entry(mp.get("name").toString(),mp.get("buynum").toString()));
        }
        return ents;
    }

    private class Entry{
        public String name;
        public String value;

        public Entry(String name, String value) {
            this.name = name;
            this.value = value;
        }
    }
}
